import { UserQueryList, UserQuery } from "@/type";
import qs from "qs";
import request from "@/utils/request";

export async function getUserList(params?: UserQueryList) {
    // const res = await axios(`https://mock.apifox.cn/m1/2398938-0-default/api/Users?${qs.stringify(params)}`)
    return request.get(`/api/users?${qs.stringify(params)}`)
}

export async function userAdd(params?: UserQuery) {
    return request.post('/api/users', params);
}

export async function userDelete(id?: string) {
    return request.delete(`/api/users/${id}`);
}

export async function userUpdate(id: string, params: UserQuery) {
    return request.put(`/api/users/${id}`, params);
}

export async function getUserDetail(id?: string) {
    return request.get(`/api/users/${id}`);
}

export async function login(params: Pick<UserQuery, "name" | "password">) {
    return request.post('/api/users/login', params);
}

export async function logout() {
    // return request.get('/api/logout');
}